/*!
 * Header file correcponding to a album. (album.cpp)
 * @author Mazzer Yannis, Calingarayar Martial
 */
#ifndef _ALBUM_H
#define _ALBUM_H

#include <QString>
#include <QTime>
#include <QDate>
#include <QMap>
#include <QSqlTableModel>
#include <QDataWidgetMapper>
#include <QSqlRecord>
#include "ui_albumdescr.h"

/*!
 * Declaration of the TrackMap structure as a QMap of an int and a QString.
 */
typedef QMap<int,QString> TrackMap;


/*!
 * This class gather all informations about a album.
 */
class Album : public QWidget, private Ui::AlbumDescriptor
{
    Q_OBJECT
    public:

/*!
 * Album class constructor.
 * @param parent A pointer to the parent which calle the constructor.
 */
	Album(QWidget *parent = 0);

/*!
 * This function gives the number of the album.
 * @return The number of the album.
 */
	int getNumero();

/*!
 * This function gives the album title.
 * @return The album title.
 */
	QString getTitle();

/*!
 * This function gives the artist who make the album.
 * @return The name of the interpreter
 */
	QString getArtist();

/*!
 * This function gives the duration of the album.
 * @return The duration of the album.
 */
	QTime getRunningTime();

/*!
 * This function gives the date of release of album.
 * @return The date of release of album.
 */
	QDate getReleaseDate();

/*!
 * This function gives the label.
 * @return The Label of the album.
 */
	QString getLabel();

/*!
 * This function gives the composer.
 * @return The composer of the album.
 */
	QString getComposer();

/*!
 * This function gives the producer.
 * @return The producer of the album.
 */
	QString getProducer();

//	int getTrackCount();
//	QString getTrackName(const int &trackNumber);

/*!
 * This function gives the index of the class.
 * @return The index to which the class Album refers.
 */
	int getIndex();


/*!
 * Determines the index in the model.
 * @param index the new index in the model
 * @param model the model the View is related to
 */
	void setModelIndex(const QModelIndex &index, QSqlTableModel *model);

/*!
 * Function that sets track.
 */
	void trackSetUp();

/*!
 * Function that sets the number's album.
 * @param &newNumero the new number of the album.
 */
	void setNumero(const int &newNumero);

/*!
 * Function that sets the title's album.
 * @param &newTitle The new title of the album.
 */
	void setTitle(const QString &newTitle);

/*!
 * Function that sets the artist's album.
 *@param &newArtist The new artist of the album.
 */
	void setArtist(const QString &newArtist);

/*!
 * Function that sets the time's album.
 *@param &newRunningTime The new running time of the album.
 */
	void setRunningTime(const QTime &newRunningTime);

/*!
 * Function that sets the release date's album.
 *@param &newReleaseDate The new release date of the album.
 */
	void setReleaseDate(const QDate &newReleaseDate);

/*!
 * Function that sets the label's album.
 *@param &newLabel The new label of the album.
 */
	void setLabel(const QString &newLabel);

/*!
 * Function that sets the composer's album.
 *@param &newComposer The new composer of the album.
 */
	void setComposer(const QString &newComposer);

/*!
 * Function that sets the producer's album.
 *@param &newProducer The new producer of the album.
 */
	void setProducer(const QString &newProducer);

//	void addOrModTrack(const int &trackNumber, const QString &trackName);
//	void delTrack(const int &trackNumber);
//	void delTrack(const QString &trackName);

    private slots:
/*!
 * This slot actually draw the widget and its content, it sets the
 * widgets positions. And finally shows it.
 */
	void draw();

/*!
 * This slot is used to relocate the index in the model when the latter has
 * been resetted. it uses the unique id from the database to do it.
 */
	void resetIndex();

    private:
	int numero;
	QString title;
	QString artist;
	QTime runningTime;
	QDate releaseDate;
	QString	label;
	QString support;
	QString composer;
	QString producer;
	QSqlRecord record;
	QDataWidgetMapper *mapper;
	QSqlTableModel *mod;
	QSqlTableModel *trackModel;

	TrackMap tracks;

};

#endif // _ALBUM_H
